package com.autumn.zero.workflow.constants;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.autumn.common.api.domain.values.IntegerConstantItemValue;

/**
 * 流程设计常量
 * 
 * @author 杨昌国 2018-12-21 12:20:58
 */
public final class ProcessDesignStatusConstants implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5846735789606819488L;

	/**
	 * 未发布
	 */
	public static final int NOT_PUBLISH = 1;

	/**
	 * 已发布
	 */
	public static final int PUBLISH = 2;

	/**
	 * 卸载
	 */
	public static final int UNINSTALL = 3;

	private static final Map<Integer, IntegerConstantItemValue> NAME_MAP = new HashMap<>();

	static {
		NAME_MAP.put(NOT_PUBLISH, new IntegerConstantItemValue(NOT_PUBLISH, "待发布", ""));
		NAME_MAP.put(PUBLISH, new IntegerConstantItemValue(PUBLISH, "已发布", ""));
		NAME_MAP.put(UNINSTALL, new IntegerConstantItemValue(UNINSTALL, "卸载", ""));
	}

	/**
	 * 是否存在
	 * 
	 * @param value 值
	 * @return
	 */
	public static boolean exist(Integer value) {
		if (value == null) {
			return false;
		}
		return NAME_MAP.containsKey(value);
	}

	/**
	 * 获取名称
	 * 
	 * @param value 值
	 * @return
	 */
	public static String getName(Integer value) {
		IntegerConstantItemValue item = NAME_MAP.get(value);
		if (item == null) {
			return "";
		}
		return item.getName();
	}

	/**
	 * 项目集合
	 * 
	 * @return
	 */
	public static Collection<IntegerConstantItemValue> items() {
		return NAME_MAP.values();
	}

}
